import { Module, Global } from '@nestjs/common'
import { TypeOrmModule } from '@nestjs/typeorm'
import { ConfigModule, ConfigService } from '@nestjs/config'
import configuration from 'src/config/configuration'
import { models } from '../entities'
import { PassportModule } from '@nestjs/passport'
@Global()
@Module({
  imports: [
    PassportModule,
    ConfigModule.forRoot({
      envFilePath: `.env.${process.env.NODE_ENV}`,
      isGlobal: true,
      load: [configuration],
    }),
    TypeOrmModule.forRootAsync({
      useFactory: (config: ConfigService): any => config.get('database'),
      inject: [ConfigService],
    }),
    models,
  ],
  controllers: [],
  providers: [],
  exports: [models, PassportModule],
})
export class CommonModule {}
